package com.fusion.lottery.auth.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fusion.lottery.auth.service.LoginService;
import com.fusion.lottery.entity.auth.Login;
import com.fusion.lottery.entity.auth.WxLogin;
import com.fusion.utils.json.Msg;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * token控制类
 * @ClassName: TokenController 
 * @Description: TODO
 * @author louis
 * @date 2018年3月29日 上午11:08:14
 */
@Api(description="token接口")
@RestController
@RequestMapping(value = "/login")
public class LoginController {
	
	@Autowired
	private LoginService loginService;
	
	@ApiOperation(value="用户登录", notes="用户登录")
	@ApiImplicitParam(name = "login", value = "登录实体", required = true, dataType = "Login")
	@PostMapping
	public Msg login(@Valid @RequestBody Login login) {
		return loginService.login(login);
	}
	
	@ApiOperation(value="小程序用户登录", notes="小程序用户登录")
	@ApiImplicitParam(name = "wxLogin", value = "微信用户登录实体", required = true, dataType = "WxLogin")
	@PostMapping("/wx")
	public Msg wxLogin(@Valid @RequestBody WxLogin wxLogin) {
		return loginService.wxLogin(wxLogin);
	}
}